package thread;

//写法二:子类实现 Runnable接口, Runnable 就是在描述一个任务
class MyThread3 implements Runnable {
    @Override
    public void run() {
        while (true) {
            // run方法中的逻辑,是在新创建出来的线程中,被执行的代码
            System.out.println("hello thread!");
            try {
                // 让该线程休眠 ms ---> 强制让线程阻塞
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
public class TestDemo3 {
    public static void main(String[] args) {
        Thread t1 = new Thread(new MyThread3());
        t1.start();
    }
}
